package homework.day03;

import java.io.*;

public class Test03 {
    public static void main(String[] args) throws IOException {
        //创建指定的目录对象
        File dir = new File("./src/main/java/io");
        //获取该目录下的所有.java文件
        File[] subs = dir.listFiles((f) -> f.getName().endsWith(".java"));
        //遍历所有的.java文件
        for (int i = 0; i < subs.length; i++) {
            //创建指向.java文件的引用
            File sub = subs[i];
            //创建文件输入流对象
            FileInputStream fis = new FileInputStream(sub);
            //创建转换输入流对象
            InputStreamReader isr = new InputStreamReader(fis);
            //创建缓冲字符输入流对象
            BufferedReader br = new BufferedReader(isr);
            //定义字符串变量line
            String line;
            //按行读取.java文件中每一行字符串
            while ((line = br.readLine()) != null) {
                //从控制台输出读取到的每一行字符串
                System.out.println(line);
            }
            //关闭缓冲字符输入流
            br.close();
        }
    }
}
